package com.uu.it.tracker.preferences;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.TextView;
import android.widget.Toast;



public class mainmenu extends Activity {
    private static final int MENU_PREFERENCES = 1;
	private static final int MENU_ABOUT = 2;
	//private static final int MENU_QUIT = 3;
	private static final int SUBMENU_PERSONALINFO = 4;
	private static final int SUBMENU_TWITTERSETTINGS = 5;
	Intent myIntent1;
	Intent myIntent2;
	
	
	
		/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        setContentView(tv); 
        tv.setText("click the menu");

    }
    
    /* Creates the menu items */
    public boolean onCreateOptionsMenu(Menu menu) {
    	boolean result = super.onCreateOptionsMenu(menu);
    	
        menu.add(0, MENU_ABOUT, 2, "About");	
        //menu.add(0, MENU_QUIT, 3, "Exit");  
        SubMenu preference_submenu = menu.addSubMenu(0,MENU_PREFERENCES,1,"Preferences");
        
        
        MenuItem personalinfo_menuitem = preference_submenu.add(1,SUBMENU_PERSONALINFO,1,"Personal info");
        MenuItem twittersettings_menuitem = preference_submenu.add(1,SUBMENU_TWITTERSETTINGS,2,"Twitter settings");
        
        /*personalinfo_menuitem.setIntent(new Intent(this,  PersonalInfoMenu.class));
        twittersettings_menuitem.setIntent(new Intent(this, TwitterSettingsMenu.class));*/
        
        myIntent1 = new Intent(this, PersonalInfoMenu.class);
        personalinfo_menuitem.setIntent(myIntent1);
        myIntent2 = new Intent(this, TwitterSettingsMenu.class);
        twittersettings_menuitem.setIntent(myIntent2);
        
        return result;
    }
    
    /* Handles item selections */
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case MENU_PREFERENCES:
            return true;
        case MENU_ABOUT:
        	AlertDialog.Builder alert = new AlertDialog.Builder(this);
    		alert.setTitle("About");
    		alert.setMessage("Welcome to Walkmeter application. This shows you your status whether you" +
    				" are walking or running or staying idle. Click on the Results tab to see your daily " +
    				"statistics. Click on preferences to change your Settings"); 
            return true;
        /*case MENU_QUIT:
        	Toast.makeText(this,"menu quit",Toast.LENGTH_SHORT).show();
        	return true;*/
        }
        
        startActivityForResult(myIntent1, 0);
        startActivityForResult(myIntent2, 0);
        return false;
    }
    
    
    
}